
//
//  FourVC.m
//  yuanjiang
//
//  Created by YuanJiang on 2019/9/19.
//  Copyright © 2019 llbt. All rights reserved.
//

#import "FourVC.h"
#import <objc/runtime.h>

@interface FourVC ()
{
    NSString *_bbbb;
}
@property(nonatomic,strong) NSMutableArray *aaaa;

@end

@implementation FourVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.navigationItem.title = @"获取所有的私有属性和方法";
    
    [self getAllPrivateProperty];
    
    [self getAllMethod];
}

-(void)getAllPrivateProperty
{
    unsigned int count = 0;
    Ivar *ivarList = class_copyIvarList([self class], &count);
    for (int i =0; i<count; i++) {
        Ivar ivar = ivarList[i];
        NSString *ivarName = [NSString stringWithUTF8String:ivar_getName(ivar)];
        NSString *ivarType = [NSString stringWithUTF8String:ivar_getTypeEncoding(ivar)];
        NSLog(@"属性%@\n%@",ivarName,ivarType);
    }
}

-(void)getAllMethod
{
    unsigned int count = 0;
    Method *methodList = class_copyMethodList([self class], &count);
    for (unsigned int i = 0; i<count; i++) {
        Method method = methodList[i];
        NSString *methodName = NSStringFromSelector(method_getName(method));
        NSLog(@"方法名==========%@",methodName);
    }
}

@end
